﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Common.Eventing.Tests
{
    [TestClass]
    public class an_event_registration
    {
        [TestMethod]
        public void should_handle_theType_that_itWas_given()
        {
            EventRegistration<List<string>> reg = new EventRegistration<List<string>>(
                delegate(List<string> strList)
                {
                    // nothing to do
                });

            Assert.AreEqual<Type>(typeof(List<string>), reg.HandledEventType);
        }

        [TestMethod]
        public void should_equal_itself()
        {
            EventRegistration<List<string>> reg = new EventRegistration<List<string>>(
                   delegate(List<string> strList)
                   {
                       // nothing to do
                   });

            Assert.IsTrue(reg.Equals(reg));
            Assert.AreEqual<EventRegistration<List<string>>>(reg, reg);
        }

        [TestMethod]
        public void should_call_the_EventHandler_it_was_constructed_with()
        {
            bool handlerWasRaised = false;

            EventRegistration<List<string>> reg = new EventRegistration<List<string>>(
                   delegate(List<string> strList)
                   {
                       handlerWasRaised = true;
                   });

            reg.Handle(new List<string>());

            Assert.IsTrue(handlerWasRaised);
        }
    }
}
